<?php
namespace App\Traits;

use App\Models\FakeList;
use Illuminate\Http\Request;

Trait Trait45_47 {

    public function lightingList()
    {
        $data = FakeList::select(['id', 'name', 'message', 'status'])->wherein('id', [69, 70, 71, 72, 73, 74, 75, 76])->get();
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

    public function allOperate(Request $request)
    {
        $validate = $request->validate(
            [
                'operate' => 'required|integer'
            ]
        );
        $data = FakeList::wherein('id', [69, 70, 71, 72, 73, 74, 75, 76])->update(['status' => $validate['operate']]);
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

    public function oneOperate(Request $request)
    {
        $validate = $request->validate(
            [
                'id' => 'required|integer|in:69,70,71,72,73,74,75,76',
                'operate' => 'required|integer'
            ]
        );
        $data = FakeList::where(['id' => $validate['id']])->update(['status' => $validate['operate']]);
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

}
